﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using University.Workshop.Presenters.WaterPurchase;

namespace University.Workshop.Presentation.WaterPurchase
{
    /// <summary>
    /// Interaction logic for PageRegisterView.xaml
    /// </summary>
    public partial class PageRegisterView : Page, Presenters.WaterPurchase.IRegisterNewWaterPurchaseView
    {
        PresenterRegisterNewWaterPurchaseView pRegisterNewWaterPurchaseView;

        public PageRegisterView()
        {
            pRegisterNewWaterPurchaseView = new PresenterRegisterNewWaterPurchaseView(this);
            InitializeComponent();
        }

        private void btnCancelRegister_Click(object sender, RoutedEventArgs e)
        {
            RestartRegisterWaterPurchase();
        }

        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            pRegisterNewWaterPurchaseView.GoNextPage();
        }

        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            pRegisterNewWaterPurchaseView.GoBackPage();
        }

        private void btnRegisterUser_Click(object sender, RoutedEventArgs e)
        {
            RegisterBasicValue.WaterPurchaseToRegister.UserId = MainWindow.idUsuarioActivo;

            pRegisterNewWaterPurchaseView.RegisterWaterPurchase();
        }

        private void GoStepTwo_Click(object sender, RoutedEventArgs e)
        {
            pRegisterNewWaterPurchaseView.GoStepTwo();
        }

        private void GoStepOne_Click(object sender, RoutedEventArgs e)
        {
            pRegisterNewWaterPurchaseView.GoStepOne();
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            frmContent.Navigate(new PageFirstStepRegisterWaterPurchase(pRegisterNewWaterPurchaseView));
            pRegisterNewWaterPurchaseView.FirstTime();
        }

        #region IRegisterNewWaterPurchaseView Members

        IRegisterBasicView RegisterBasicValue;

        public void CallSecondPage()
        {
            PageSecondStepRegisterWaterPurchase pp = new PageSecondStepRegisterWaterPurchase(pRegisterNewWaterPurchaseView);
            RegisterBasicValue = pp;
            frmContent.NavigationService.Navigate(pp);
            GoStepTwo.IsEnabled = true;
        }

        public void CallFirstPage()
        {
            PageFirstStepRegisterWaterPurchase pp = new PageFirstStepRegisterWaterPurchase(pRegisterNewWaterPurchaseView);
            RegisterBasicValue = pp;
            frmContent.NavigationService.Navigate(pp);
        }

        public IRegisterBasicView RegisterBasic
        {
            get
            {
                return RegisterBasicValue;
            }
            set
            {
                RegisterBasicValue = value;
            }
        }

        public void SystemMessage(string MessageValue)
        {
            MessageBox.Show(App.Current.MainWindow, MessageValue, "Atencion!!!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RightAlign);
        }

        public void ErrorMessage(string MessageValue)
        {
            MessageBox.Show(App.Current.MainWindow, MessageValue, "Error!!!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.RightAlign);
        }

        public void RestartRegisterWaterPurchase()
        {
            this.NavigationService.Navigate(new PageRegisterView());
        }

        #endregion
    }
}
